package cn.epsilon3.mybatis.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import cn.epsilon3.constant.Base;
import cn.epsilon3.domain.e3.po.E3RolePo;
import cn.epsilon3.mybatis.mapper.E3RoleMapper;
import cn.epsilon3.mybatis.service.E3RoleMapperService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * user mapper 服务
 * </p>
 *
 * @author epsilon3
 * @since 2023-08-13
 */
@Service
public class E3RoleMapperServiceImpl implements E3RoleMapperService {

    @Resource
    private E3RoleMapper e3RoleMapper;

    @Override
    @Transactional(readOnly = true)
    public E3RolePo selectOneByRoleId(String roleId) {
        if (StrUtil.isBlank(roleId)) {
            return null;
        }
        return e3RoleMapper.selectOne(Wrappers.<E3RolePo>lambdaQuery()
                .eq(E3RolePo::getId, roleId)
                .eq(E3RolePo::getEffective, Base.INT0));
    }

    @Override
    public List<E3RolePo> selectAll() {
        return e3RoleMapper.selectList(Wrappers.<E3RolePo>lambdaQuery()
                .eq(E3RolePo::getEffective, Base.INT0));
    }
}
